﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Slb.Ocean.Core;
using Slb.Ocean.Basics;
using System.ComponentModel;
using Slb.Ocean.Petrel.Basics;
using Slb.Ocean.Petrel.DomainObject;
using Slb.Ocean.Petrel.UI;

namespace Public.Ocean.Petrel.Extensions.Services
{
    public static class DomainObjectExtensions
    {
        private static PetrelServiceWrapper Wrap(object obj)
        {
            IPerTypeServiceProvider services;
            if (CoreSystem.State != SystemState.None)
            {
                services = CoreSystem.Services;
            }
            else
            {
                services = new DefaultPerTypeServiceProvider();
            }
        
            return new PetrelServiceWrapper(services, obj ?? "NULL");
        }

        /// <summary>
        /// Gets all the associated Petrel services for this object.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <returns></returns>
        public static PetrelServiceWrapper PetrelServices(this object obj) { return Wrap(obj); }
    }
}
